use actix_web::web;
use serde::{Serialize, Deserialize};

#[derive(Serialize,Debug,Clone,sqlx::FromRow)]
pub struct Teacher{
    pub id: i32,
    pub name: String,
    pub profile: String,
    pub picture_url: String,
}

#[derive(Deserialize,Debug,Clone,sqlx::FromRow)]
pub struct CreateTeacher {
    pub picture_url: Option<String>,
    pub name: Option<String>,
    pub profile: Option<String>,

}

#[derive(Deserialize,Debug,Clone,sqlx::FromRow)]
pub struct UpdateTeacher {
    pub picture_url: Option<String>,
    pub name: Option<String>,
    pub profile: Option<String>,
}

impl From<web::Json<UpdateTeacher>> for UpdateTeacher {
    fn from(update: web::Json<UpdateTeacher>) -> Self {
        update.into_inner()
    }
}

impl From<web::Json<CreateTeacher>> for CreateTeacher {
    fn from(update: web::Json<CreateTeacher>) -> Self {
        update.into_inner()
    }
}
impl From<web::Json<Teacher>> for Teacher{
    fn from(teacher: web::Json<Teacher>) -> Self {
        teacher.into_inner()
    }
}